<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定位-居中</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .fa {
            width: 800px;
            height: 500px;
            background: pink;
            margin: 0 auto;
            /* 子绝父相 */
            /* 父相：父亲设置为 相对定位 */
            position: relative;
        }
        .son {
           width: 100px;
           height: 100px;
           background: palegreen;
           /* 子绝：儿子设置 绝对定位 */
           position: absolute;
           left: 50%;
           margin-left: -50px;
           top: 50%;
           margin-top: -50px;
        }
    </style>
</head>
<body>
    <div class="fa">
        <div class="son">儿子</div>
    </div>
</body>
</html>